how does ` cat << EOF` work in bash?
Posted
by hasen j
on Stack Overflow
See other posts from Stack Overflow
or by hasen j
Published on 2010-03-23T13:57:35Z
Indexed on
2010/03/23
14:13 UTC
Read the original article
Hit count: 461
I needed to write a script to enter multi-line input to a program (psql
)
After a big of googling, I found the following syntax works:
cat << EOF | psql ---params
BEGIN;
`pg_dump ----something`
update table .... statement ...;
END;
EOF
This correctly concatenates all these strings and passes the result as an input to psql.
but I have no idea how/why it works, can some one please explain?
I'm referring mainly to cat << EOF
, I know >
outputs to a file, >>
appends to a file, <
reads input from file.
What does <<
exactly do?
And is there a man page for it?
© Stack Overflow or respective owner